import React, {Component,} from 'react'
import {connect,} from 'react-redux'

class EventFilterList extends Component {
    

    render() {
        let matchesAfterFilter = []
        let eventFilters = this.props.eventFilters
        let matches = this.props.matches

        if (eventFilters.length > 0) {
            for (let i = 0; i < matches.length; i++) {
                let match = matches[i]
                if (eventFilters.find(event => event.value.id === match[1])) {
                    matchesAfterFilter.push(match)
                }
            }
            matches = matchesAfterFilter
        }
        return <>
            {this.props.render(matches)}
        </>
    }

}


const mapState = (state) => ({
    eventFilters: state.game.eventFilters,
})

export default connect(mapState)(EventFilterList)
